<?php
class M_DbTable_Visa extends Apps_Db_Table_Abstract {
	protected $_name = 'article';

	const STATUS_ACTIVE  	= 1;
	const STATUS_INACTIVE  	= 0;
	const STATUS_DELETED  	= -1;

	public function getList() {
		$q = $this->_db
				  ->select()
				  ->from(array('a'   => $this->_name), null)
				  ->where('a.reference_type =?', M_DbTable_Article::REFERENCE_TYPE_VISA)
				  ->where('a.status =?', self::STATUS_ACTIVE)
				  ->order('a.created_date DESC')
				  ->columns(
				  		array('id'						=>  'a.id',
							  'title'					=>	'a.title',
							  'en_title'				=>	'a.en_title',
				  			  'description'				=>	'a.description',
				  			  'created_date'			=>	'a.created_date'
				  ));
		return $q;
	}

	public function getVisa($id) {
		$q = $this->_db
				  ->select()
				  ->from(array('a'   => $this->_name), null)
				  ->where('a.reference_type =?', M_DbTable_Article::REFERENCE_TYPE_VISA)
				  ->where('a.status =?', self::STATUS_ACTIVE)
				  ->where('a.id =?', $id)
				  ->columns(
				  		array('id'						=>  'a.id',
							  'title'					=>	'a.title',
							  'en_title'				=>	'a.en_title',
				  			  'overview'				=>	'a.overview',
				  			  'en_overview'				=>	'a.en_overview',
				  			  'detail'					=>	'a.detail',
				  			  'en_detail'				=>	'a.en_detail'
				  ));
		return $q;
	}
}